package com.glory.erp.invoice.operdetail.action;

import java.util.List;

import com.glory.erp.invoice.operdetail.service.OperDetailService;
import com.glory.erp.invoice.operdetail.bean.OperDetail;
import com.glory.erp.invoice.operdetail.bean.OperDetailQuery;
import com.glory.erp.auth.base.BaseAction;

public class OperDetailAction extends BaseAction{
	public OperDetail operDetail = new OperDetail();
	public OperDetailQuery operDetailQuery = new OperDetailQuery();

	private OperDetailService operDetailService;
	public void setOperDetailService(OperDetailService operDetailService) {
		this.operDetailService = operDetailService;
	}

	//列表
	public String list(){
		setDataTotal(operDetailService.getCount(operDetailQuery));
		List<OperDetail> operDetailList = operDetailService.findAll(operDetailQuery,pageNum,pageCount);
		put("operDetailList", operDetailList);
		return LIST;
	}

	//到添加
	public String addView(){
		if(operDetail.getUuid()!=null){
			operDetail = operDetailService.findById(operDetail.getUuid());
		}
		return ADD;
	}

	//添加
	public String saveAndUpdate(){
		if(operDetail.getUuid() == null){
			operDetailService.save(operDetail);
		}else{
			operDetailService.update(operDetail);
		}
		return TO_LIST;
	}

	//删除
	public String delete(){
		operDetailService.delete(operDetail);
		return TO_LIST;
	}

}
